/*
 * @Author: lihaogn
 * @Date: 2021-05-31 23:58:52
 * @LastEditTime: 2022-01-23 21:09:52
 * @LastEditor: lihaogn
 * @Description: 路由
 * @FilePath: \lix-admin-server\app\router.js
 */
"use strict";

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = (app) => {
  const { router, controller, jwt, io } = app;

  router.get("/", jwt, controller.home.index);
  // 登录
  router.post("/api/login", controller.login.login);

  /**
   * 用户
   */
  // 导入用户
  router.post("/api/user/import", jwt, controller.user.import);
  // 对 admin（用户） 的增删改查的接口 - restful
  router.resources("user", "/api/user", jwt, controller.user);

  /**
   * 角色
   */
  router.resources("role", "/api/role", jwt, controller.role);

  /**
   * 权限
   */
  router.resources("permission", "/api/permission", jwt, controller.permission);

  /**
   * 文件上传与下载
   */
  router.post("/api/upload", jwt, controller.upload.upload);
  router.get("/api/uploadList", jwt, controller.upload.getList);
  router.delete("/api/deleteUpload", jwt, controller.upload.deleteUpload);
  router.get("/api/download", jwt, controller.upload.download);

  // socket.io
  // io.of('/')
  //   .route('server', io.controller.default.ping);
};
